package com.sky.mapper;

import com.sky.aop.AutoFill;
import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

@Mapper
public interface UserMapper {

    /**
     * 微信用户登录
     * @param user
     */
    @Insert("insert into user values (null, #{openid}, #{name}, #{phone}, #{sex}" +
            ",#{idNumber}, #{avatar}, #{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertUser(User user);

    /**
     * 根据openId查询用户
     * @param openId
     * @return
     */
    @Select("select * from user where openid = #{openId}")
    User selectByOpenId(String openId);

    /**
     * 根据时间查询用户数量
     * @param queryParam
     * @return
     */
    Long selectCountByMap(Map<String, Object> queryParam);
}
